package com.leetcode.LC;

import java.util.HashSet;

public class LC961 {
    public int repeatedNTimes(int[] A) {

        HashSet<Integer> set = new HashSet<>();

        for (int i : A) {
            if (set.contains(i)) {
                return i;
            } else {
                set.add(i);
            }
        }

        return -1;
    }

    public static void main(String[] args) {
        System.out.println(new LC961().repeatedNTimes(new int[]{5, 1, 5, 2, 5, 3, 5, 4}));
    }
}
